import java.util.*;
//牛客网微信红包问题

public class Gift {
    public int getValue(int[] gifts, int n) {
     
      Arrays.sort(gifts);//从小到大
        
        int money = gifts[n/2];
        int count = 0;
        for (int i = 0; i < gifts.length; i++) {//遍历红包,看要找的金额是不是等于该下标的值
            if(gifts[i] == money) {
                count++;
            }
        }
        //走到这一步说明遍历完了,看count的值
        return count <= n/2 ? 0 : money;
    }
}

        
    
